package arch.coal.ellipse.security.data;


import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * Make this an ENTRY_TYPE enum
 *  'G' = GLOBAL PROFILE
 *  'S' = INDIVIDUAL USERS
 *  'P' = PROGRAMS
 * 
 * This is an implementation of the 'Serializable Ordinal-Based Typesafe enum Pattern'
 * @author mblackford
 *
 */
public class Entry_Type implements Serializable {
	
	private static final long serialVersionUID = -8372281495863530555L;
	private final transient String name;
	private static int nextOrdinal = 0;
	private final int ordinal = nextOrdinal++;
	
	private Entry_Type(String n) {
		name = n;
	}

	public String toString() {
		return name;
	}
	
	private Object readResolve() throws ObjectStreamException {
		return PRIVATE_VALUES[ordinal];
	}
	
	public final static Entry_Type GLOBAL_PROFILE 	= new Entry_Type("G");
	public final static Entry_Type INDIVIDUAL_USER 	= new Entry_Type("S");
	public final static Entry_Type PROGRAMS 		= new Entry_Type("P");
	
	private static final Entry_Type[] PRIVATE_VALUES = 
		{ GLOBAL_PROFILE, INDIVIDUAL_USER, PROGRAMS };
	
	public static final List VALUES = 
		Collections.unmodifiableList(Arrays.asList(PRIVATE_VALUES));
	
}
